<!---
	Title:		Elders Program Database Service Plan
	Author:		Bruce Frick
	Purpose:	.
--->

<cfset BASE = CreateObject("component", "cfc.base") />
<cfparam name="url.ElderID" default="0">
<cfparam name="url.PlanID" default="-1">

<cfoutput>
<!---HTML header, css links, js links, and page title--->
#BASE.htmlHeader("/jquery/ui-1.8.5/jquery-ui.min.js,js/serviceplan.js",
	"css/style.css,/jquery/ui-1.8.5/themes/base/jquery-ui.css",
    "Elders Program - Service Plan",
    url.ElderID)#
<!---HTML header, css links, js links, and page title--->

<cfform id="myform">

<cfset QUERIES.ServicePlans = CreateObject("component", "cfc.queries").funcQrySelectServicePlans(URL.ElderID, -1)/>
<cfset QUERIES.ServicePlan = CreateObject("component", "cfc.queries").funcQrySelectServicePlanByID(url.PlanID)/>
<cfset QUERIES.elder = CreateObject("component", "cfc.queries").funcQryGetIntakeByID(url.ElderID) />
<cfset QUERIES.ElderPriority = CreateObject("component", "cfc.queries").funcQryGetElderPriority(url.ElderID) />

<cfinput type="hidden" id="ElderID" name="ElderID" value="#url.ElderID#" />
<cfinput type="hidden" id="PlanID" name="PlanID" value="#url.PlanID#" />
<cfset SESSION.ElderID = URL.ElderID />

<table width="99%" cellpadding="2" cellspacing="2" id="service_plan">
	<tbody class="header_title">
        <tr>
            <td valign="top" width="75%">
            	<h2>Service Plan</h2>
            </td>
            <td valign="top">
        	   <cfselect id="serivce_plans" name="serivce_plans" >
                	<option value="-1">- New Service Plan -</option>
	                <cfloop query="QUERIES.ServicePlans">
	                	<option value="#QUERIES.ServicePlans.PlanID#"
						<cfif url.PlanID eq QUERIES.ServicePlans.PlanID>selected="selected"</cfif>>
	                    	#dateFormat(QUERIES.ServicePlans.PlanDate, 'mm/dd/yyyy')# - ID: #QUERIES.ServicePlans.PlanID#
	                    </option>
	                </cfloop>
                </cfselect>
            </td>
        </tr>
    </tbody>
</table>

<table width="99%" cellpadding="2" cellspacing="2" id="service_plan" style="font-weight:bold; color:##000; font-size:12px">
	<tbody class="body">
		<tr>
        	<td colspan="3" class="black_spacer" style="color:##FFF;font-size:16px;">Elder Information</td>
        </tr>
		<tr>
        	<td>
            	<table cellpadding="2" cellspacing="2" id="iadl" width="100%" >
                	<tr>
                        <td align="left">

                            <div>Elder Name:</div>
                            <cfselect id="elder" name="elder" >
                                <option value="-1">- Choose Elder -</option>
                            <cfset QUERIES.eldersNoContact = CreateObject("component", "cfc.queries").funcQryAllEldersNoContacts() />
                            <cfloop query="QUERIES.eldersNoContact">
                                <cfif url.ElderID eq ELDERLISTID>
                                    <option value="#ELDERLISTID#" selected="selected">#LASTNAME#, #FIRSTNAME#</option>
                                <cfelse>
                                    <option value="#ELDERLISTID#">#LASTNAME#, #FIRSTNAME#</option>
                                </cfif>
                            </cfloop>
                            </cfselect>
                        </td>
                        <td align="left">
                            <div>DOB: </div>
                            <cfinput type="text" id="DOB" name="DOB" disabled="disabled" size="10" value="#QUERIES.elder.DOB#" />
                        </td>
                        <td align="left">
                            <div>Date of Contact: </div>
                            <cfinput type="text" id="PlanDate" name="PlanDate" size="10" onBlur="validDate(this)"
                            value="#QUERIES.ServicePlan.PlanDate#"  />
                        </td>
                        <td align="left">
                            <div>Next Evaluation: </div>
                            <cfinput type="text" id="EvalDateShow"
                                name="EvalDateShow" disabled="disabled" size="10" value="#QUERIES.ServicePlan.EvalDate#"/>
                                <cfinput type="hidden" id="EvalDate"
                                name="EvalDate" value="#QUERIES.ServicePlan.EvalDate#"/>
                        </td>                        
                        <td align="left" valign="top">
                            <div>Acuity Level: </div>
                            #QUERIES.ElderPriority.PriorityName#
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" align="left">
                            <div>Elder Provider:</div>
                            <cfset QUERIES.providers = CreateObject("component", "cfc.utilities").funcGetDLProviders() />
                            <cfselect name="ProviderID">
                                <option value="-1" > </option>
                                <cfloop from="1" to="#ArrayLen(QUERIES.providers)#" index="i">
                                    <option value="#QUERIES.providers[i].RosettaID#"
                                    <cfif QUERIES.elder.ProviderID eq QUERIES.providers[i].RosettaID> selected="selected"</cfif> >
                                    #QUERIES.providers[i].FirstName# #QUERIES.providers[i].LastName#</option>
                                </cfloop>
                            </cfselect>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="left">
                            <div>Personal Care Attendant (if applicable):</div>
                                <cfinput type="text" id="CareAttendant" name="CareAttendant"  size="80"
                                value="#QUERIES.ServicePlan.CareAttendant#" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="left">
                            <div>Care Coordinator (if applicable):</div>
                                <cfinput type="text" id="CareCoordinator" name="CareCoordinator"  size="80"
                                value="#QUERIES.ServicePlan.CareCoordinator#" />
                        </td>
                    </tr>
               </table>
           </td>
        </tr>
        <!---<tr>
        	<td colspan="3" class="black_spacer" style="color:##FFF;font-size:16px;">Acuity</td>
        </tr>
         <tr>
        	<td colspan="3">
				<!--- inner table Instrumental Activities of Daily Living (IADL) --->
                <table cellpadding="2" cellspacing="2" id="iadl" >
                	<tbody>
                    	<tr>
                            <td>
                            	<div>Preparing Meals:</div>
                            	<cfselect id="PreparingMeals" name="PreparingMeals">
                                	<option value="1" <cfif QUERIES.ServicePlan.PreparingMeals eq 1>selected="selected"</cfif>>
                                    	Independent (1 Point)
                                    </option>
                                    <option value="2" <cfif QUERIES.ServicePlan.PreparingMeals eq 2>selected="selected"</cfif>>
                                    	Independent, with great difficulty (2 Points)
                                    </option>
                                    <option value="3" <cfif QUERIES.ServicePlan.PreparingMeals eq 3>selected="selected"</cfif>>
                                    	With assistance from a helper (3 Points)
                                    </option>
                                    <option value="4" <cfif QUERIES.ServicePlan.PreparingMeals eq 4>selected="selected"</cfif>>
                                    	Unable to complete, helper does all of the work (4 Points)
                                    </option>
                                </cfselect>
                            <td>
                            	<div>How does the customer currently manage:</div>
                            	<cfinput type="text" id="PreparingMealsManage" name="PreparingMealsManage" size="50"
                                value="#QUERIES.ServicePlan.PreparingMealsManage#"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            	<div>Doing Housework:</div>
                            	<cfselect id="DoingHouseWork" name="DoingHouseWork">
                                	<option value="1" <cfif QUERIES.ServicePlan.DoingHouseWork eq 1>selected="selected"</cfif>>
                                    	Independent (1 Point)
                                    </option>
                                    <option value="2" <cfif QUERIES.ServicePlan.DoingHouseWork eq 2>selected="selected"</cfif>>
                                    	Independent, with great difficulty (2 Points)
                                    </option>
                                    <option value="3" <cfif QUERIES.ServicePlan.DoingHouseWork eq 3>selected="selected"</cfif>>
                                    	With assistance from a helper (3 Points)
                                    </option>
                                    <option value="4" <cfif QUERIES.ServicePlan.DoingHouseWork eq 4>selected="selected"</cfif>>
                                    	Unable to complete, helper does all of the work (4 Points)
                                    </option>
                                </cfselect>
                            </td>
                            <td>
                            	<div>How does the customer currently manage:</div>
                                <cfinput type="text" id="DoingHouseWorkManage" name="DoingHouseWorkManage" size="50"
                                value="#QUERIES.ServicePlan.DoingHouseWorkManage#"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            	<div>Doing Laundry:</div>
                            	<cfselect id="DoingLaundry" name="DoingLaundry">
                                	<option value="1" <cfif QUERIES.ServicePlan.DoingLaundry eq 1>selected="selected"</cfif>>
                                    	Independent (1 Point)
                                    </option>
                                    <option value="2" <cfif QUERIES.ServicePlan.DoingLaundry eq 2>selected="selected"</cfif>>
                                    	Independent, with great difficulty (2 Points)
                                    </option>
                                    <option value="3" <cfif QUERIES.ServicePlan.DoingLaundry eq 3>selected="selected"</cfif>>
                                    	With assistance from a helper (3 Points)
                                    </option>
                                    <option value="4" <cfif QUERIES.ServicePlan.DoingLaundry eq 4>selected="selected"</cfif>>
                                    	Unable to complete, helper does all of the work (4 Points)
                                    </option>
                                </cfselect>
                            </td>
                            <td>
                            	<div>How does the customer currently manage:</div>
                            	<cfinput type="text" id="DoingLaundryManage" name="DoingLaundryManage" size="50"
                                value="#QUERIES.ServicePlan.DoingLaundryManage#"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            	<div>Doing Shopping:</div>
                            	<cfselect id="DoingShopping" name="DoingShopping">
                                	<option value="1" <cfif QUERIES.ServicePlan.DoingShopping eq 1>selected="selected"</cfif>>
                                    	Independent (1 Point)
                                    </option>
                                    <option value="2" <cfif QUERIES.ServicePlan.DoingShopping eq 2>selected="selected"</cfif>>
                                    	Independent, with great difficulty (2 Points)
                                    </option>
                                    <option value="3" <cfif QUERIES.ServicePlan.DoingShopping eq 3>selected="selected"</cfif>>
                                    	With assistance from a helper (3 Points)
                                    </option>
                                    <option value="4" <cfif QUERIES.ServicePlan.DoingShopping eq 4>selected="selected"</cfif>>
                                    	Unable to complete, helper does all of the work (4 Points)
                                    </option>
                                </cfselect>
                            </td>
                            <td>
                            	<div>How does the customer currently manage:</div>
                            	<cfinput type="text" id="DoingShoppingManage" name="DoingShoppingManage" size="50"
                                value="#QUERIES.ServicePlan.DoingShoppingManage#"/>
                           </td>
                        </tr>
                        <tr>
                        	<td>
                            	<!--- inner table Instrumental Activities of Daily Living (IADL) --->
                               <div ><!---class="instructions"--->
                                   <div>
                                        IADLs Total = <span id="iadl_total">#QUERIES.ServicePlan.IADLTotal#</span>
                                        <cfinput type="hidden" name="IADLTotal" value="#QUERIES.ServicePlan.IADLTotal#" />
                                   </div>
                                   <div>
                                        Acuity Level:
                                        <cfset QUERIES.acuityLevels = CreateObject('component', 'cfc.queries').funcQryAllAcuityLevels("All") />
                                        <cfselect id="PriorityID" name="PriorityID" >
                                        <option value="-1" > </option>
                                        <cfloop query="QUERIES.acuityLevels">
                                        <option value="#PriorityID#" <cfif QUERIES.elder.PriorityID eq PriorityID>selected="selected"</cfif>>
                                            #PriorityName#
                                        </option>
                                        </cfloop>
                                        </cfselect><br />
                                        <span id="acuity_totals"></span>
                                   </div>
                               </div>
                            </td>
                        </tr>
                    </tbody>
                </table>

            </td>
        </tr> --->
        <tr>
        	<td colspan="3" class="black_spacer" style="color:##FFF;font-size:16px;">Services</td>
        </tr>
        <tr>
			<td colspan="3" >
				<!--- inner table Services --->
                <table cellpadding="2" cellspacing="2" width="96%" class="service_plan">
                	<tbody >
                    	<tr>
							<td width="15%">Services</td>
                            <td>Times Per Month</td>
                            <td>
                            	Does another agency or caregiver (including family/friends) provide this service already?
                            	Please document who.
                            </td>
                        </tr>
                    </tbody>
                	<tbody>
                    	<tr>
							<td>Light Meal Prep</td>
                            <td><cfinput type="text" id="MealPreparation" name="MealPreparation" 
                            	value="#QUERIES.ServicePlan.MealPreparation#" /></td>
                            <td><cfinput type="text" id="MealPreparationOther" name="MealPreparationOther"  size="69"
                            	value="#QUERIES.ServicePlan.MealPreparationOther#" /></td>
                        </tr>
                        <tr>
							<td>Light Chore</td>
                            <td><cfinput type="text" id="LightChore" name="LightChore"
                            	value="#QUERIES.ServicePlan.LightChore#" /></td>
                            <td><cfinput type="text" id="LightChoreOther" name="LightChoreOther"  size="69"
                            	value="#QUERIES.ServicePlan.LightChoreOther#"/></td>
                        </tr>
                        <tr>
							<td>In-Home Visit</td>
                            <td><cfinput type="text" id="HomeVisit" name="HomeVisit"
                            	value="#QUERIES.ServicePlan.HomeVisit#" /></td>
                            <td><cfinput type="text" id="HomeVisitOther" name="HomeVisitOther" size="69"
                            	value="#QUERIES.ServicePlan.HomeVisitOther#" /></td>
                        </tr>
                        <tr>
							<td>Group Visit</td>
                            <td><cfinput type="text" id="GroupVisit" name="GroupVisit"
                            	value="#QUERIES.ServicePlan.GroupVisit#"  /></td>
                            <td><cfinput type="text" id="GroupVisitOther" name="GroupVisitOther"  size="69"
                            	value="#QUERIES.ServicePlan.GroupVisitOther#"/></td>
                        </tr>
                        <tr>
							<td>Telephoning</td>
                            <td><cfinput type="text" id="Telephoning" name="Telephoning"
                            	value="#QUERIES.ServicePlan.Telephoning#" /></td>
                            <td><cfinput type="text" id="TelephoningOther" name="TelephoningOther"   size="69"
                            	value="#QUERIES.ServicePlan.TelephoningOther#"/></td>
                        </tr> <tr>
                            <td colspan="3">
                                Comments (to include exceptions to acuity level services,
                                either in excess or less than required service levels):
                                <br /><cftextarea id="Comments" name="Comments" >#QUERIES.ServicePlan.Comments#</cftextarea>
                            </td>
                        </tr>
                    </tbody>
                </table>
               <!--- inner table Services --->
            </td>
        </tr>
        <tr>
        	<td colspan="3">
            	<!--- inner table Signatures --->
                <table cellpadding="2" cellspacing="2" width="98%" style="font-weight:bold;">
                	<tbody>
                    	<tr>
                        	<td>                           
                                <div id="ElderSignature">Elder Signature:</div>                           
                                <cfselect id="ElderSignature" name="ElderSignature"  >
                                    <option value="no" <cfif QUERIES.ServicePlan.ElderSignature eq 'no'>selected=selected</cfif>>No</option>
                                    <option value="yes" <cfif QUERIES.ServicePlan.ElderSignature eq 'yes'>selected=selected</cfif>>Yes</option>
                                </cfselect>
                                <cfif QUERIES.ServicePlan.ElderSignature neq "" or QUERIES.ServicePlan.ElderSignature eq 'no'>
                                    <cfset ElderSignDate = dateFormat(QUERIES.ServicePlan.ElderSignatureDate, 'mm/dd/yyyy') />
                                <cfelse>
                                    <cfset ElderSignDate = dateFormat(now(), 'mm/dd/yyyy') />
                                </cfif>
                                <cfinput type="text" name="ElderSignatureDate" value="#ElderSignDate#" />
                            </td>
                            <td>
                                <div id="StaffSignature">Staff Signature:</div>
                                <cfset QUERIES.providers = CreateObject("component", "cfc.utilities").funcGetDLProviders() />                                
                                <cfif QUERIES.ServicePlan.StaffSignature eq "">
                                    <cfset staffSignDate = dateFormat(now(), 'mm/dd/yyyy')/>
                                <cfelse>
                                    <cfset staffSignDate = dateFormat(QUERIES.ServicePlan.StaffSignatureDate, 'mm/dd/yyyy')/>
                                </cfif>
                                <cfselect name="StaffSignature">
                                    <option value="-1" ></option>
                                    <cfloop from="1" to="#ArrayLen(QUERIES.providers)#" index="i">
                                        <option value="#QUERIES.providers[i].RosettaID#" <cfif QUERIES.ServicePlan.StaffSignature eq QUERIES.providers[i].RosettaID>selected=selected</cfif>>
                                            #QUERIES.providers[i].FirstName# #QUERIES.providers[i].LastName#
                                        </option>
                                    </cfloop>
                                </cfselect>
                                <cfinput type="text" id="StaffSignatureDate" name="StaffSignatureDate" value="#staffSignDate#" />
                            </td>
                            <td>
                            	<div id="SupervisorSignature">Supervisor Signature:</div>
                                <cfset UTILS = CreateObject("component", "cfc.utilities") />                      	
                                <cfset UTILS.supervisor = UTILS.funcIsSupervisor(CGI.AUTH_USER)/>
								<cfif UTILS.supervisor.RecordCount gt 0 >
									<cfif QUERIES.ServicePlan.SupervisorSignature neq "">
                                        <!--- request from customer to have this installed?! --->
                                        <cfselect name="SupervisorSignature">
                                            <option value="-1" > </option>
                                            <cfloop from="1" to="#ArrayLen(QUERIES.providers)#" index="i">
                                                <cfif trim(QUERIES.providers[i].LastName) eq "Soper" OR 
                                                        trim(QUERIES.providers[i].LastName) eq "Bauman" OR 
                                                            trim(QUERIES.providers[i].LastName) eq "Osterback">
                                                    <option value="#QUERIES.providers[i].RosettaID#" <cfif QUERIES.providers[i].RosettaID EQ QUERIES.ServicePlan.SupervisorSignature > selected='selected' </cfif>>
                                                        #QUERIES.providers[i].FirstName# #QUERIES.providers[i].LastName#
                                                    </option>                                                  
                                                </cfif>
                                            </cfloop>
                                        </cfselect>
                                        <cfinput type="text" name="SupervisorSignatureDate" value="#dateFormat(QUERIES.ServicePlan.SupervisorSignatureDate, 'mm/dd/yyyy')#" />
                                    <cfelse>
                                    
                                        <!--- request from customer to have this installed?! --->
                                        <cfselect name="SupervisorSignature">
	                                        <option value="-1" > </option>
	                                        <cfloop from="1" to="#ArrayLen(QUERIES.providers)#" index="i">
                                                <cfif trim(QUERIES.providers[i].LastName) eq "Soper" OR 
                                                        trim(QUERIES.providers[i].LastName) eq "Bauman" OR 
                                                            trim(QUERIES.providers[i].LastName) eq "Osterback">
                                                    <option value="#QUERIES.providers[i].RosettaID#" <cfif QUERIES.providers[i].RosettaID EQ QUERIES.ServicePlan.SupervisorSignature > selected='selected' </cfif>>
                                                        #QUERIES.providers[i].FirstName# #QUERIES.providers[i].LastName#
                                                    </option>	                                               
                                                </cfif>
	                                        </cfloop>
                                        </cfselect>                                       
                                        <cfinput type="text" id="SupervisorSignatureDate" name="SupervisorSignatureDate" value="#dateFormat(now(), 'mm/dd/yyyy')#" />
                                    </cfif>

                                <cfelseif UTILS.supervisor.RecordCount eq 0 AND QUERIES.ServicePlan.SupervisorSignature neq "">                                    
                                    <cfselect name="StaffSignature">
                                        <cfloop from="1" to="#ArrayLen(QUERIES.providers)#" index="i">
                                            <option value="#QUERIES.providers[i].RosettaID#" 
                                            <cfif QUERIES.providers[i].RosettaID EQ QUERIES.ServicePlan.SupervisorSignature > selected='selected' </cfif> > 
                                            #QUERIES.providers[i].FirstName# #QUERIES.providers[i].LastName#</option>
                                        </cfloop>
                                    </cfselect>
                                    <cfinput type="text" id="SupervisorSignatureDate" name="SupervisorSignatureDate" value="#dateFormat(QUERIES.elder.SupervisorSignatureDate, 'mm/dd/yyyy')#" />
                                <cfelse>
                                	Your are not a supervisor
                                    <cfinput type="hidden" id="SupervisorSignature" name="SupervisorSignature"
                                       size="15" value="" />
                                        <cfinput type="hidden" id="SupervisorSignatureDate" name="SupervisorSignatureDate"
                                        value="" />
                                </cfif>
                            </td>
                        </tr>
                    </tbody>
                </table>
               <!--- inner table Signatures--->
            </td>
        </tr>
        <tr>
        	<td colspan="3">
            	<cfinput type="button" id="new_serviceplan" name="new_serviceplan"  value="New Service Plan" />
                <cfset UTILS.supervisor = CreateObject("component", "cfc.utilities").funcIsSupervisor(CGI.AUTH_USER)/>
				<cfif UTILS.supervisor.RecordCount gt 0 >
                	<cfinput type="button" id="edit_serviceplan" name="edit_serviceplan"  value="Edit Service Plan" />
               		<cfinput type="button" id="delete_serviceplan" name="delete_serviceplan"  value="Delete Service Plan" />
                </cfif>

            </td>
        </tr>
    </tbody>
</table>

<!---this holds the logged in user for data submition.--->
<input type="hidden" id="signer" value="#CGI.AUTH_USER#" />

<!---this holds todays date for data submition.--->
<input type="hidden" id="sign_date" value="#dateFormat(now(),'mm/dd/yyyy')#" />
</cfform>

<!---HTML footer, closes html and body tags.  Any footer info goes here--->
#BASE.htmlFooter()#
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
</cfoutput>